package com.xiaoxi.statemode.state;

import com.xiaoxi.statemode.context.Context;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.statemode.state
 * @ClassName DayState
 * @Description TODO
 * @Date 2023/3/27 21:30
 * @Version 1.0
 */
public class DayState implements State {

    private String name;
    private static DayState dayState = new DayState("白天");

    private DayState(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static DayState getInstance() {
        return dayState;
    }

    @Override
    public void doClock(Context context, int hour) {
        if (hour < 9 || hour >= 17) {
            context.changeState(NightState.getInstance());
        } else if (hour == 12) {
            context.changeState(LunchState.getInstance());
        }
    }

    @Override
    public void doUse(Context context) {
        context.recordLog("正常使用金库，保存一条记录");
    }

    @Override
    public void doAlarm(Context context) {
        context.callSecurityCenter("紧急！按下警铃（白天）");
    }

    @Override
    public void doPhone(Context context) {
        context.callSecurityCenter("正常呼叫！！！（白天）");
    }
}
